﻿using Excel2DbTool.Common;
using Excel2DbTool.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace Excel2DbTool.Helpers
{
    /*
	public class HTableMigrater : DbTableMigrater
	{
		public HTableMigrater()
		{
		}



		public override void Execute()
		{
			DataTable dt = GetDataWhichNeedInsertToTable();

			for (int i = 0; i < dt.Rows.Count; i++)
			{
				DbRowMapping dbrm = new DbRowMapping();

				for (int j = 0; j < dt.Columns.Count; j++)
				{
					var val = dt.Rows[i][j];
					dbrm.AddFieldMapping(new DbFieldMapping(val));
				}

				DbRowMappings.Add(dbrm);
			}


			InsertDataToDb();
		}

		DataTable GetDataWhichNeedInsertToTable()
		{
			string sql = String.Format("SELECT {0} FROM {1}", getFieldNeedRslove(), ConfigHelper.TableName);
			return SqlHelper.GetInstance().Select(sql);
		}

		String getFieldNeedRslove()
		{
			return string.Join(",", FieldMappings.Keys);
		}

		void InsertDataToDb()
		{
			String insertSql = "";
			SqlHelper.GetInstance().Insert(insertSql);
		}


	}
    */
    /*
      -- Create table
create table BDC_H
(
  fwid       NVARCHAR2(12) not null,
  hh         NVARCHAR2(20),
  fwbh       NVARCHAR2(30),
  ch         NVARCHAR2(10),
  dyh        NVARCHAR2(10),
  dymc       NVARCHAR2(20),
  ljzh       NVARCHAR2(24),
  sjc        NVARCHAR2(10),
  myc        NVARCHAR2(10),
  zzlc       NVARCHAR2(10),
  ycjzmj     FLOAT,
  yctnjzmj   FLOAT,
  ycftjzmj   FLOAT,
  ycdxbfjzmj FLOAT,
  ycqtjzmj   FLOAT,
  ycftxs     FLOAT,
  scjzmj     FLOAT,
  sctnjzmj   FLOAT,
  scftjzmj   FLOAT,
  scdxbfjzmj FLOAT,
  scqtjzmj   FLOAT,
  scftxs     FLOAT,
  hx         NVARCHAR2(4),
  hxjg       NVARCHAR2(4),
  gytdmj     FLOAT,
  fttdmj     FLOAT,
  dytdmj     FLOAT,
  fwlx       NVARCHAR2(4),
  fwxz       NVARCHAR2(32),
  fwjg       NVARCHAR2(4),
  fdcpmt     NVARCHAR2(200),
  jgsj       DATE,
  cqly       NVARCHAR2(200),
  qxdm       NVARCHAR2(10),
  mjdw       INTEGER,
  blzt       INTEGER,
  bz         NVARCHAR2(200),
  ljzid      NVARCHAR2(20),
  cid        NVARCHAR2(40),
  mph        NVARCHAR2(50),
  slid       CHAR(20),
  bdcdyh     NVARCHAR2(28),
  fwyt1      NVARCHAR2(32),
  fwyt2      NVARCHAR2(32),
  fwyt3      NVARCHAR2(32),
  ljzmc      NVARCHAR2(50),
  slid2      CHAR(20),
  hzl        NVARCHAR2(100),
  zrzh       NVARCHAR2(20),
  xmid       NVARCHAR2(36),
  bazt       NVARCHAR2(20),
  ygzt       NVARCHAR2(20),
  cqzt       NVARCHAR2(20),
  yyzt       NVARCHAR2(20),
  dyqzt      NVARCHAR2(20),
  dyzt       NVARCHAR2(20),
  cfzt       NVARCHAR2(20),
  zrzid      NVARCHAR2(36),
  cjsj       DATE,
  cjr        NVARCHAR2(50),
  xgsj       DATE,
  xgr        NVARCHAR2(50),
  sfhbcf     INTEGER default 0 not null,
  sfxzsj     INTEGER default 1 not null,
  kssynx     DATE,
  jssynx     DATE,
  zcs        INTEGER,
  hbhs       INTEGER default 1 not null,
  tdyt       NVARCHAR2(32),
  qlxz       INTEGER
)
tablespace BDCDJ0616
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 2M
    next 8K
    minextents 1
    maxextents unlimited
  );
-- Add comments to the columns 
comment on column BDC_H.fwid
  is '房屋ID';
comment on column BDC_H.hh
  is '户号';
comment on column BDC_H.fwbh
  is '房屋编号';
comment on column BDC_H.ch
  is '层号';
comment on column BDC_H.dyh
  is '单元号';
comment on column BDC_H.dymc
  is '单元名称';
comment on column BDC_H.ljzh
  is '逻辑幢号';
comment on column BDC_H.sjc
  is '实际层';
comment on column BDC_H.myc
  is '名义层';
comment on column BDC_H.zzlc
  is '终止楼层';
comment on column BDC_H.ycjzmj
  is '预测建筑面积';
comment on column BDC_H.yctnjzmj
  is '预测套内建筑面积';
comment on column BDC_H.ycftjzmj
  is '预测分摊建筑面积';
comment on column BDC_H.ycdxbfjzmj
  is '预测地下部分建筑面积';
comment on column BDC_H.ycqtjzmj
  is '预测其它建筑面积';
comment on column BDC_H.ycftxs
  is '预测分摊系数';
comment on column BDC_H.scjzmj
  is '实测建筑面积';
comment on column BDC_H.sctnjzmj
  is '实测套内建筑面积';
comment on column BDC_H.scftjzmj
  is '实测分摊建筑面积';
comment on column BDC_H.scdxbfjzmj
  is '实测地下部分建筑面积';
comment on column BDC_H.scqtjzmj
  is '实测其它建筑面积';
comment on column BDC_H.scftxs
  is '实测分摊系数';
comment on column BDC_H.hx
  is '户型';
comment on column BDC_H.hxjg
  is '户型结构';
comment on column BDC_H.gytdmj
  is '共有土地面积';
comment on column BDC_H.fttdmj
  is '分摊土地面积';
comment on column BDC_H.dytdmj
  is '独用土地面积';
comment on column BDC_H.fwlx
  is '房屋类型';
comment on column BDC_H.fwxz
  is '房屋性质';
comment on column BDC_H.fwjg
  is '房屋结构';
comment on column BDC_H.fdcpmt
  is '房地产平面图';
comment on column BDC_H.jgsj
  is '竣工时间';
comment on column BDC_H.cqly
  is '产权来源';
comment on column BDC_H.qxdm
  is '区县代码';
comment on column BDC_H.mjdw
  is '面积单位';
comment on column BDC_H.blzt
  is '办理状态';
comment on column BDC_H.bz
  is '备注';
comment on column BDC_H.ljzid
  is '逻辑幢ID';
comment on column BDC_H.cid
  is '层ID';
comment on column BDC_H.mph
  is '门牌号';
comment on column BDC_H.slid
  is '受理号';
comment on column BDC_H.bdcdyh
  is '不动产单元号';
comment on column BDC_H.fwyt1
  is '房屋用途1';
comment on column BDC_H.fwyt2
  is '房屋用途2';
comment on column BDC_H.fwyt3
  is '房屋用途3';
comment on column BDC_H.ljzmc
  is '逻辑幢名称';
comment on column BDC_H.slid2
  is '受理号2';
comment on column BDC_H.hzl
  is '户坐落';
comment on column BDC_H.zrzh
  is '自然幢号';
comment on column BDC_H.xmid
  is '项目ID';
comment on column BDC_H.bazt
  is '备案状态';
comment on column BDC_H.ygzt
  is '预告状态';
comment on column BDC_H.cqzt
  is '产权状态';
comment on column BDC_H.yyzt
  is '异议状态';
comment on column BDC_H.dyqzt
  is '地役状态';
comment on column BDC_H.dyzt
  is '抵押状态';
comment on column BDC_H.cfzt
  is '查封状态';
comment on column BDC_H.zrzid
  is '自然幢ID';
comment on column BDC_H.cjsj
  is '创建时间';
comment on column BDC_H.cjr
  is '创建人';
comment on column BDC_H.xgsj
  is '修改时间';
comment on column BDC_H.xgr
  is '修改人';
comment on column BDC_H.sfhbcf
  is '是否合并拆分';
comment on column BDC_H.sfxzsj
  is '是否现状数据';
comment on column BDC_H.kssynx
  is '开始使用年限';
comment on column BDC_H.jssynx
  is '结束使用年限';
comment on column BDC_H.zcs
  is '总层数';
comment on column BDC_H.hbhs
  is '每层所占户数';
comment on column BDC_H.tdyt
  is '土地用途';
comment on column BDC_H.qlxz
  is '权利性质';
-- Create/Recreate indexes 
create index BDC_H_ZRZID on BDC_H (ZRZID)
  tablespace BDCDJ0616
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 128K
    next 1M
    minextents 1
    maxextents unlimited
  );
-- Create/Recreate primary, unique and foreign key constraints 
alter table BDC_H
  add constraint BDC_H primary key (FWID)
  using index 
  tablespace BDCDJ0616
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 128K
    next 1M
    minextents 1
    maxextents unlimited
  );
     */

}
